<?php

/*

COMP 353F
Dr. B Desai
Final Project
Group #11

6330746 Nicholas CONSTANTINIDIS
9532862 Jacqueline FU
5484537 Claudio Javier LOPEZ FLORES
9218416 Que Tung NGUYEN

*/

  session_start();
?>

<!DOCTYPE html>
<html lang="en">
<head>
        <title>CoBAGSys - Home</title>
        <link type="text/css" rel="stylesheet" href="css/mystyle.css">
        <script type="text/JavaScript" src="js/validate.js"></script>
        <script type="text/JavaScript">
        <!--
        function ValidateFields() {
	        return ValidateFieldNumeric("searchForm", "minprice", "minimum price")
	        && ValidateFieldNumeric("searchForm", "maxprice", "maximum price")
	        && ValidateFieldDate("searchForm", "mindate", "'date posted from'")
	        && ValidateFieldDate("searchForm", "maxdate", "'date posted up to'");
        }
        //-->
        </script>
</head>
<body>
    <?php
      require 'menus.php';
    ?>
    <div id="main">
      	<p class="title">
      		Search
      	</p>
		<form id="searchForm" action="postings.php" onsubmit="return ValidateFields();" method="get">
			<table border="0">
				<tr>
					<td class="normal">Keyword</td>
					<td class="normal"><input type="text" name="search"></td>
				</tr>
				<tr>
					<td class="normal">Category</td>
					<td class="normal">
<?php
	$rows = getCategoriesForMenu();
	
	if (isset($rows))
	{
		$rowcount = count($rows);
		print "<select name=\"cid\">";
		print "<option value=\"\">Any</option>";
		for ($i = 0; $i < $rowcount; $i++)
		{
			print "<option value=\"" . $rows[$i]['cid'] . "\">" . $rows[$i]['cName'] . "</option>";
		}
		print "</select>";
	}
?>					
					</td>
				</tr>
				<tr>
					<td class="normal">Type</td>
					<td class="normal">
						<select name="type">
							<option value="">Any</option>
							<option value="bid">Sell</option>
							<option value="barter">Barter</option>
						</select>
					</td>
				</tr>
				<tr>
					<td class="normal">City</td>
					<td class="normal"><input type="text" name="city"></td>
				</tr>
				<tr>
					<td class="normal">Price from</td>
					<td class="normal"><input type="text" size="5" name="minprice"> $</td>
				</tr>
				<tr>
					<td class="normal">Price up to</td>
					<td class="normal"><input type="text" size="5" name="maxprice"> $</td>
				</tr>
				<tr>
					<td class="normal">Posted between</td>
					<td class="normal"><input type="text" maxlength="10" size="10" name="mindate" placeholder="yyyy-mm-dd">
					and <input type="text" maxlength="10" size="10" name="maxdate" placeholder="yyyy-mm-dd"></td>
				</tr>
			</table>
			<p></p>
			<input type="submit" class="largeButton" value="Search"/>
		</form>
    </div>
</body>
</html>